<template>
	<view class="content">
		<view class="assetbag">
			<view class="assetbag-wrap">
				<view class="assetbag-hader">
					<view class="header-l">
						<image class="bgimage" :src="wxuser.pic ? wxuser.pic  : user.userPhoto"></image>
					</view>
					<view class="header-r">
						<view class="userinfo">
							<view>{{user.userName}}</view>
							<view v-if="user.is_vip" class="hytip">会员</view>
						</view>
						<view class="usermobile">
							<view>{{user.userPhone}}</view>
							<view style="margin-left: 10px;">消费奖励：{{user.gg_credit | moneyFilter}}</view>
						</view>
						<view class="usermobile">
							<view class="cash" @click="cash" style="margin-left: 10px;">兑换</view>
							<view class="cash" @click="tobuylist" style="margin-left: 30px;">购买列表</view>
						</view>
					</view>
				</view>
				<view class="assetbag-content">
					<view class="myprove">
						<view class="prove">
							<view>我的消费积分</view>
							<view class="commcolor" style="padding: 3px 0px;">总资产</view>
							<view class="commcolor">≈{{userinfo.total_cert_num}}</view>
						</view>
						<view class="prove">
							<view>今日释放</view>
							<view class="commcolor">≈{{userinfo.today_res}}</view>
						</view>
						<view class="prove">
							<view>今日加速</view>
							<view class="commcolor">≈{{userinfo.today_dt}}</view>
						</view>
					</view>
					<view style="padding: 10px;display: flex;justify-content: flex-end;" @click="toexchange">查看释放记录</view>
					<view class="todayprice">
						<view class="newest"><text>{{pricedetail.price}}</text>今日价格</view>
						<view class="buy" @click="sell('buy')">买入</view>
						<view class="sell" @click="sell('sell')">卖出</view>
					</view>
				</view>
			</view>
			<view class="assetbag-list">
				<view class="list" v-for="(item,index) in assetbaglist" :key="index">
					<view class="cell-wrap">
						<view class="cell-l">
							<image class="bgimage" src="../../static/emptyCart.jpg" mode=""></image>
						</view>
						<view class="cell-r">
							<view>{{item.name}}</view>
							<view class="flex_">
								<view>编号：{{item.kjbh}}</view>
								<view>每日释放数量：{{item.every_day_rlease}} </view>
							</view>
							<view>预计释放总量：{{item.num}}</view>
							<view class="flex_">
								<view>累计已释放：{{item.already_profit | moneyFilter}}</view>
								<view class="exchange">{{item.conduct_type == 2 ? '消费奖励' : '消费积分'}}</view>
							</view>
						</view>
					</view>
				</view>
				<!-- 		<view class="list-tab">
					<view class="tabcolor activecolor">涨幅榜</view>
					<view class="tabcolor">跌幅榜</view>
				</view>
				<view class="list-cell">
					<view class="cell-wrap">
						<view class="commflex">
							<view class="flex1">交易对</view>
							<view class="flex1 price">价格</view>
							<view class="flex1">涨幅跌</view>
						</view>
						<view class="commflex">
							<view class="flex1 lx">
								<text class="fontcolor">BTC</text>/
								<text class="normal">USDT</text>
							</view>
							<view class="flex1" style="text-align: center;">
								<view class="color1">￥0.2456</view>
								<view class="color2">￥0.2345</view>
							</view>
							<view class="flex1">
								<view class="rosebtn">+35.14%</view>
							</view>
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import {
		userInfo
	} from "@/common/loadUserInfo.js"
	export default {
		data() {
			return {
				user: {},
				userinfo: {},
				assetbaglist: [],
				pricedetail: {},
				wxuser:{}
			}
		},
		onShow() {
			this.loaddata()
			this.mybag()
			this.getprice()
			userInfo({
				success: (res) => {
					this.user = res.data.userinfo
					uni.setStorageSync('userDetail', this.user)
					uni.stopPullDownRefresh()
				},
				fail: (err) => {
					console.log(err)
				}
			})
			if(uni.getStorageSync('user')){
				this.wxuser = uni.getStorageSync('user')
			}
		},
		onLoad() {

		},
		methods: {
			toexchange() {
				uni.navigateTo({
					url: '../exchangelist/exchangelist?type=2'
				})
			},
			tobuylist() {
				uni.navigateTo({
					url: '/subPackage/buyinglist/buyinglist'
				})
			},
			loaddata() {

				let that = this;
				uni.request({
					url: 'https://www.ggshop1688.com/api/transaction/zcbreleasedata',
					method: 'POST',
					header: {
						token: uni.getStorageSync('userInfo').token
					},
				}).then(data => {
					this.userinfo = data[1].data.data
					console.log(data)
					console.log(this.userinfo)
				})
			},
			mybag() {
				let that = this;
				uni.request({
					url: 'https://www.ggshop1688.com/api/conduct/profit',
					method: 'POST',
					header: {
						token: uni.getStorageSync('userInfo').token
					},
				}).then(data => {
					this.assetbaglist = data[1].data.data.list
				})
			},
			getprice() {
				let that = this;
				uni.request({
					url: 'https://www.ggshop1688.com/api/transaction/config',
					method: 'POST',
					header: {
						token: uni.getStorageSync('userInfo').token
					},
				}).then(data => {
					this.pricedetail = data[1].data.data[0]
					this.pricedetail.price = this.pricedetail.price
				})
			},
			cash() {
				uni.navigateTo({
					url: '../cashlist/cashlist'
				})
			},
			sell(type) {
				if (type == 'buy') {
					uni.navigateTo({
						url: '../buying/buying?type=' + 1
					})

				} else {

					uni.navigateTo({
						url: '../buying/buying?type=' + 2
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.assetbag {
		background-color: #fbefe4;
		font-size: 24upx;
		height: 100vh;

		.assetbag-wrap {

			.assetbag-hader {
				background-color: rgb(238, 91, 37);
				// margin-bottom: 20upx;
				padding: 0px 0px 20upx 0px;
				position: relative;
				color: #fff;
				height: 260upx;

				.header-l {
					width: 100upx;
					height: 100upx;
					position: absolute;
					right: 10%;
					bottom: 40%;

					.bgimage {
						width: 100%;
						height: 100%;
						border-radius: 50%;

						img {
							width: 100%;
							height: 100%;
						}
					}
				}

				.header-r {
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					margin-left: 20upx;

					.userinfo {
						display: flex;
						height: 40upx;
						line-height: 40upx;
						align-items: center;

						.hytip {
							height: 30upx;
							line-height: 30upx;
							background-color: #027aff;
							color: #fff;
							width: 80upx;
							text-align: center;
							border-radius: 10upx;
							margin-left: 20upx;
						}
					}

					.usermobile {
						display: flex;
						align-items: center;
						padding: 10px 0px;
					}

					.cash {
						background-color: #f6a283;
						color: #000;
						width: 160upx;
						height: 60upx;
						line-height: 60upx;
						text-align: center;
						border-radius: 10px;
						margin-right: 10px;
						padding-bottom: 10px;
					}
				}
			}

			.assetbag-content {
				background-color: #fbefe4;
				padding: 40upx;
				border-radius: 10px;
				position: relative;
				margin-top: -40upx;

				.myprove {
					display: flex;
					justify-content: space-between;
					background-color: #fff;
					padding: 20upx;
					border-radius: 10px;
					box-shadow: inset 0px 0px 0px 2px #f2f2f2;

					.commcolor {
						color: #ee5b25;
					}

					.prove {
						width: 33%;
						flex-direction: column;
						justify-content: space-around;
						display: flex;
						text-align: center;
						// border: 1px solid #999;
						box-sizing: border-box;
						border-radius: 5px;
						border-right: 1px solid #f2f2f2;
					}
				}

				.prove:last-child {
					border: none;
				}

				.todayprice {
					display: flex;
					align-items: center;
					padding: 20upx 0upx;

					.newest {
						width: 60%;
						height: 40upx;
						line-height: 40upx;
						text-align: center;
					}

					.buy {
						width: 200upx;
						height: 60upx;
						line-height: 60upx;
						background-color: #ee5b25;
						color: #fff;
						text-align: center;
					}

					.sell {
						width: 200upx;
						height: 60upx;
						line-height: 60upx;
						background-color: #027aff;
						color: #fff;
						text-align: center;
						margin-left: 20upx;
					}
				}
			}
		}

		.assetbag-list {
			background-color: #fff;
			border-radius: 10px;
			min-height: 300px;
			padding: 10px;

			.list {
				border: 1px solid #f2f2f2;
				border-radius: 7px;
				padding: 20upx 0px 20upx 20upx;
				background-color: #fff;
				margin-bottom: 10px;

				.cell-wrap {
					display: flex;

					.cell-l {
						width: 160upx;
						height: 160upx;
						margin-right: 20upx;

						.bgimage {
							width: 100%;
							height: 100%;
						}
					}

					.cell-r {
						width: 73%;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.flex_ {
							// margin-top: 80upx;
							display: -webkit-box;
							display: -webkit-flex;
							display: flex;
							justify-content: space-between;
							align-items: center;

							.exchange {
								width: 140upx;
								border-radius: 3px;
								height: 40upx;
								line-height: 40upx;
								background-color: #027aff;
								color: #fff;
								text-align: center;
							}
						}
					}
				}
			}

			.list-tab {
				display: flex;
				padding: 10px 0px 0px 0px;
				border-bottom: 1px solid #fadecb;
				margin-bottom: 10px;

				.tabcolor {
					color: #999;
					padding-bottom: 10px;
					padding: 0px 15px;
				}

				.activecolor {
					border-bottom: 1px solid #ee5b25;
					color: #ee5b25;
					padding-bottom: 10px;
				}
			}

			.list-cell {
				border: 1px solid #f2f2f2;
				border-radius: 7px;
				padding: 20upx;
				background-color: #fff;

				.cell-wrap {
					.commflex:last-child {
						padding: 15px 0px;
					}

					.commflex {
						display: flex;
						align-items: center;

						.rosebtn {
							color: #fff;
							background-color: #cb4d1f;
							font-size: 14px;
							text-align: center;
							width: 140upx;
							height: 25px;
							line-height: 25px;
							margin: 0 auto;
						}

						.flex1 {
							flex: 1;

							.color1 {
								color: #ee5b25;
								font-size: 15px;
							}

							.color2 {
								color: #ccc;
								font-size: 18upx;
							}
						}

						.flex1:last-child {
							text-align: center;
						}

						.price {
							text-align: center;
						}

						.lx {
							.fontcolor {
								font-weight: 600;
								color: #333;
								font-size: 15px;
							}

							.normal {
								font-weight: 500;
								font-size: 18upx;
								color: #ccc;
							}
						}
					}

					.cell-l {
						width: 160upx;
						height: 160upx;
						margin-right: 20upx;

						.bgimage {
							width: 100%;
							height: 100%;
						}
					}

					.cell-r {
						width: 65%;
						line-height: 2;
					}
				}
			}
		}
	}
</style>
